﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.Model;
using System.Data;
using RoadTeam.Enums;
using RoadTeam.SysInterface;

namespace RoadTeam.BsSystem.CS.HomeInspection
{
   public class TbCsValidateObject_Sys : ICsValidateObject
    {

        public String GetValidateObjectID(String Identifier)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsValidateObject() { App_Identifier = Identifier };
            where.SelectColumn = @" top 1 validateobjectid  ";
            DataTable dt = TbCsValidateObject.Select(where, GlobalConfig.RtConnectionString);
            if (dt.Rows.Count == 0) return @"-1";
            return dt.Rows[0][0].ToString();
        }

        public String GetValidateObjectIdentifier(String objectID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsValidateObject() { ValidateObjectID =Convert.ToDecimal(objectID)};
            where.SelectColumn = @" top 1 App_Identifier  ";
            DataTable dt = TbCsValidateObject.Select(where, GlobalConfig.RtConnectionString);
            if (dt.Rows.Count == 0) return @"-1";
            return dt.Rows[0][0].ToString();
        }

       public DataTable GetValidateObjectTable(String OrganID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsValidateObject() { OrganID = Convert.ToDecimal(OrganID) };
            where.StrSqlWhere = @"   App_Identifier Is  NULL   ";
            where.SelectColumn = @"  ValidateObjectName,ValidateObjectCode,MaintenanceTime,App_Identifier,OrganID,ValidateObjectID ";
            return TbCsValidateObject.Select(where, GlobalConfig.RtConnectionString);
        }

       public DataTable GetValidateObjectData(String InID)
       {
           SqlWhere where = new SqlWhere();
           where.StrSqlWhere = @"   ValidateObjectID    IN (" + InID + ")";
           //where.SelectColumn = @"  ValidateObjectName,ValidateObjectCode,MaintenanceTime,App_Identifier,OrganID,ValidateObjectID ";
           return TbCsValidateObject.Select(where, GlobalConfig.RtConnectionString);
       }






        public bool UpdateValidateObjectTable(DataTable dt)
        {
            return TbCsValidateObject.Update(dt, GlobalConfig.RtConnectionString);
        }





    }
}
